<?php
/**
 * 通用右侧调用接口
 * User: lmx
 * Date: 2018/3/27
 * Time: 14:43
 */
require '../common.inc.php';
if (isset($_GET['cats']) and strlen(trim($_GET['cats'])) > 0) {
    $cat_arr = explode('|', $_GET['cats']);
    $return=array();
    foreach ($cat_arr as $key=>$item) {
        $arr = explode(',',$item);
        $temp=array();
        if (count($arr) == 3) {
            $mid = $arr[0];
            $cid = $arr[1];
            $size = $arr[2];
            $result = $db->query("SELECT title,headline,thumb,linkurl FROM {$db->pre}article_$mid WHERE catid=$cid and status=3 order by level desc,addtime desc limit $size",'CACHE');
            while($r = $db->fetch_array($result)) {
                $r['headline']=$r['headline']==''?$r['title']:$r['headline'];
                $temp[] = $r;
            }

        }
        $return[] = $temp;
    }

    if(isset($_GET['callback'])){
        echo $_GET['callback']."(".json_encode($return).")";
    }
}